-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Login 2fa (totp) #1680
base: master
Are you sure you want to change the base?
Login 2fa (totp) #1680
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
export function generateTotpSecret ({ label = 'stacker.news - login' }) { | ||
const totp = getTotp({ label }) | ||
return { | ||
base32: totp.secret.base32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is the setup-key in google authenticator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the design goals of this and the code looks pretty straightforward.
This will need very careful focused review and QA from both @ekzyis and I. At least on my part, I likely won't get to deep review until after jan 3.
Description
Add optional TOTP 2fa for login.
Partially solves: #1439
Screenshots
Additional Context
next-auth does not support 2fa natively.
There are several ways to implement it, but i've come up with this custom solution that is tailored to sn.
The goals of this implementation are:
To achieve this i've implemented 2fa as two middlewares:
Most of the logic is contained in
/lib/auth2fa
As reference i've used the github 2fa flow.
Checklist
Are your changes backwards compatible? Please answer below:
yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
6
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
not yet
Did you introduce any new environment variables? If so, call them out explicitly here:
no